<admintpl file="header" />
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('RechargeRebate/index')}">卡充值返利配置</a></li>
			<li class="active"><a href="{:U('RechargeRebate/add',array('id'=>empty($item['id'])?'':$item['id']))}" target="_self">添加</a></li>
		</ul>
		<form action="{:U('RechargeRebate/add_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data" onsubmit="return submitform();">
			<div class="row-fluid">
				<div class="span9">
					<table class="table table-bordered">
						<tr>
							<th>金额范围<span class="form-required">*</span></th>
							<td>
                                <input type="text" name="start_price" id="start_price" value="{$item.start_price}" style="width: 100px"  placeholder="起始金额">
                                至
                                <input type="text" name="end_price" id="end_price" value="{$item.end_price}" style="width: 100px" placeholder="结束金额"> </td>
						</tr>
						<tr>
							<th>返利比例<span class="form-required">*</span></th>
							<td><input type="text" name="rebate_percent" id="rebate_percent" value="{$item.rebate_percent}" style="width: 400px" placeholder="请输入返利比例">% </td>
						</tr>
                    </table>
				</div>

			</div>
			<div class="form-actions">
                <input type="hidden" name="id" value="{$item.id}"/>
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="{:U('RechargeRebate/index')}">返回</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
    <script>
        function submitform(){
            var start_price = $('#start_price').val();
            var end_price = $('#end_price').val();
            var rebate_percent = $('#rebate_percent').val();
            start_price = parseFloat(start_price);
            end_price = parseFloat(end_price);
            rebate_percent = parseFloat(rebate_percent);
            if(start_price == ''){
                alert('起始金额不能为空!');return false;
            }
            if(isNaN(start_price)){
                alert('起始金额输入有误!');return false;
            }
            if(end_price == ''){
                alert('结束金额不能为空!');return false;
            }
            if(isNaN(end_price)){
                alert('结束金额输入有误!');return false;
            }
            if(rebate_percent == ''){
                alert('返利比例不能为空!');return false;
            }
            if(end_price<start_price){
                alert('金额输入有误!');return false;
            }

            if(isNaN(rebate_percent) || rebate_percent<0 || rebate_percent >100){
                alert('返利比例输入有误!');return false;
            }

            return true;
        }
    </script>
	</body>
</html>